package k2_oop.p9_collection.demo07;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class FootballTeam {

    /**
     * 初始化16支足球队
     * @return
     */
    public List<String> initFootballTeam(){

        return Arrays.asList(
                "科特迪瓦",
                "阿根廷",
                "澳大利亚",
                "塞尔维亚",
                "荷兰",
                "尼日利亚",
                "日本",
                "美国",
                "中国",
                "新西兰",
                "巴西",
                "比利时",
                "韩国",
                "喀麦隆",
                "洪都拉斯",
                "意大利"
        );

    }

    /**
     * 
     * @param teams
     */
    public void allot(List<String> teams){

        //作为泛型的列表表示的是每四个国家组成的一个小组，外层的列表表示的是一共是4个小组
        List<List<String>> teamGroups = new ArrayList<>();
        Collections.shuffle(teams);

        for (int i = 0; i < 4 ; i++) {
            teamGroups.add(teams.subList(4 * i, 4 * (i + 1)));
        }

        System.out.println(teamGroups);
        
    }

    public static void main(String[] args) {

        FootballTeam footballTeam = new FootballTeam();
        List<String> teams = footballTeam.initFootballTeam();
        footballTeam.allot(teams);
        
    }

}
